/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package rad.Java.MotelPlus.Class;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import rad.Java.Common.Class.DefaultClass;
import rad.Java.Common.Class.IClass;

/**
 *
 * @author Renato ferreira dos santos
 */
public class Apt extends DefaultClass implements IClass{
    // <editor-fold defaultstate="collapsed" desc="Declaration of variables">
        //public  AptType  apttype = new AptType();
        private String   _number;
        private String   _block_id;
        private StateApt _status;
        private String   _type_id;
    // </editor-fold>

    public Apt()
    {
        _gsql.setTable("apt");
        _sequence = "apt_apt_id_seq";
    }

    // <editor-fold defaultstate="collapsed" desc="Declaration of methods Get and Set">
        public String getBlockId() {
            return _block_id;
        }

        public void setBlockId(String _floor_id) {
            this._block_id = _floor_id;
        }

        public String getNumber() {
            return _number;
        }

        public void setNumber(String _number) {
            this._number = _number;
        }

        public StateApt getStatus() {
            return _status;
        }

        public void setStatus(StateApt _status) {
            this._status = _status;
        }

        public String getTypeId() {
            return _type_id;
        }

        public void setTypeId(String _type_id) {
            this._type_id = _type_id;
        }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Declaration of functions">
        public void clear() {
            _id             = "";
            _number         = "";
            _block_id       = "";
            _status         = StateApt.Livre;
            _type_id        = "";
        }

        @Override
        public void get(ResultSet rs) {
            try {
                _id             = rs.getString("apt_id");
                _number         = rs.getString("apt_number");
                _block_id       = rs.getString("apt_block_id");
                _status         = StateApt.valueOf(rs.getString("apt_status"));
                _type_id        = rs.getString("apt_type_id");      
            } catch (SQLException ex) {
                Logger.getLogger(Apt.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        @Override
        public void setGsql() {
            _gsql.setValue( _id                 , "apt_id");
            _gsql.setValue( _number             , "apt_number");
            _gsql.setValue( _block_id           , "apt_block_id");
            _gsql.setValue( _status.toString()  , "apt_status");
            _gsql.setValue( _type_id            , "apt_type_id");
        }
    // </editor-fold>
}
